package com.delaphone.flocash.web.action;

import com.delaphone.flocash.model.FUser;
import com.delaphone.flocash.service.UserService;
import com.opensymphony.xwork2.Action;
import java.math.BigDecimal;
import java.text.SimpleDateFormat;

/**
 *
 * @author tamdx
 * @track changes
 *      - 31/07/2011 (Dongtv): add code fold, get balance
 */
public class SummaryAction extends BaseAction {

    private UserService userService;
    private String lastLogin;
    private String accountType;
    private String addressVerified;
    private BigDecimal lastTx;

    public String index() {
        if (user == null) {
            return Action.ERROR;
        }
        FUser u = userService.getUserByEmail(user.getEmail());
        SimpleDateFormat df = new SimpleDateFormat("dd-MM-yyyy HH:mm:ss");
        setLastLogin(u.getLastLogin() != null ? df.format(u.getLastLogin()) : "");
        setAccountType(u.getAccountType());
        setAddressVerified(u.getAddressVerified());
        lastTx = userService.getLastTx(user.getEmail(), user.getCurrency());
        return Action.SUCCESS;
    }
    // <editor-fold defaultstate="collapsed" desc="get and set methods">

    public String getLastLogin() {
        return lastLogin;
    }

    public void setLastLogin(String lastLogin) {
        this.lastLogin = lastLogin;
    }

    public UserService getUserService() {
        return userService;
    }

    public void setUserService(UserService userService) {
        this.userService = userService;
    }

    public String getAccountType() {
        return accountType;
    }

    public void setAccountType(String accountType) {
        this.accountType = accountType;
    }

    public String getAddressVerified() {
        return addressVerified;
    }

    public void setAddressVerified(String addressVerified) {
        this.addressVerified = addressVerified;
    }
    public BigDecimal getLastTx() {
        return lastTx;
    }
    
    // </editor-fold>
}
